//
//  LuckyTodayView.m
//  Koizora
//
//  Created by dlios on 15-6-9.
//  Copyright (c) 2015年 CupCat. All rights reserved.
//

#import "LuckyTodayView.h"

@implementation LuckyTodayView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self) {
        
        self.content = [[UILabel alloc] init];
//        _content.backgroundColor = [UIColor redColor];
        [self addSubview:_content];
        
        
        self.xingyunse = [[UILabel alloc] init];
//        _xingyunse.backgroundColor = [UIColor redColor];
        [self addSubview:_xingyunse];
        self.label1 = [[UILabel alloc] init];
        [self addSubview: _label1];
        
        
        self.xingyunshu = [[UILabel alloc] init];
//        _xingyunshu.backgroundColor = [UIColor redColor];
        [self addSubview:_xingyunshu];
        self.label2 = [[UILabel alloc] init];
        [self addSubview: _label2];
        
        self.supei = [[UILabel alloc] init];
//        _supei.backgroundColor = [UIColor redColor];
        [self addSubview: _supei];
        self.label3 = [[UILabel alloc] init];
        [self addSubview:_label3];
        
        self.xz = [[UILabel alloc] init];
//        _xz.backgroundColor = [UIColor redColor];
        [self addSubview:_xz];
        
        
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _label1.frame = CGRectMake(0, self.frame.size.height / 50, self.frame.size.width / 6, 30);
    _label1.text = @"幸运色";
    _label1.textColor = [UIColor whiteColor];
    _xingyunse.frame = CGRectMake(_label1.frame.size.width, self.frame.size.height / 50,_label1.frame.size.width + _label1.frame.size.width, 30);
    _xingyunse.textColor = [UIColor whiteColor];

    
    _label2.frame = CGRectMake(0,_label1.frame.origin.y + _label1.frame.size.height + 10, self.frame.size.width / 6, 30);
    _label2.text = @"幸运数";
    _label2.textColor = [UIColor whiteColor];

    _xingyunshu.frame = CGRectMake(_label2.frame.size.width, _label1.frame.origin.y + _label1.frame.size.height + 10, _label2.frame.size.width * 2, 30);
    _xingyunshu.textColor = [UIColor whiteColor];

    
    _label3.frame = CGRectMake(0, _label2.frame.origin.y + _label2.frame.size.height + 10, self.frame.size.width / 6, 30);
    _label3.text = @"速配";
    _label3.textColor = [UIColor whiteColor];

    _supei.frame = CGRectMake(_label3.frame.size.width, _label2.frame.origin.y + _label2.frame.size.height + 10, _label3.frame.size.width * 2, 30);
    _supei.textColor = [UIColor whiteColor];

    
    CGFloat f = [[self class] heightWithText:_content.text];
    _content.numberOfLines = 0;
    _content.textColor = [UIColor whiteColor];
    _content.frame =CGRectMake(0, _label3.frame.size.height + _label3.frame.origin.y + 10 , self.frame.size.width, f);
    
    
}


// label自适应高度
+(CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
